package com.ruoyi.system.service.msg.enricher;

import com.ruoyi.system.entity.DemandChangeRequestDO;
import com.ruoyi.system.entity.MsgPushTaskDO;
import com.ruoyi.system.enums.MsgTypeEnum;
import com.ruoyi.system.service.IDemandChangeRequestService;
import com.ruoyi.system.service.msg.MsgDetailEnricher;
import com.ruoyi.system.vo.H5MsgDetailVO;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Objects;

@Component
public class RequirementChangeMsgEnricher implements MsgDetailEnricher {

    @Resource
    private IDemandChangeRequestService demandChangeRequestService;

    @Override
    public boolean supports(Integer msgType) {
        return Objects.equals(msgType, MsgTypeEnum.REQUIREMENT_CHANGE.getCode());
    }

    @Override
    public void enrich(H5MsgDetailVO vo, MsgPushTaskDO task) {
        DemandChangeRequestDO demandChangeRequestDO = demandChangeRequestService.getById(Long.valueOf(task.getBusinessId()));
        vo.setDemandChangeRequestDO(demandChangeRequestDO);
    }
}
